﻿using System.Collections.Generic;

namespace Manoso.Data.FluentMap
{
    public class FluentFactory
    {
        /// <summary>
        /// Create a map root.
        /// </summary>
        /// <typeparam name="T">Root value type.</typeparam>
        /// <returns>Map root of the given type.</returns>
        public static IFluentRoot<T> Create<T>()
        {
            var root = new Root<T>();
            var mapRoot = new Map<IRoot<T>, T>
            {
                Relation = new Relation<IRoot<T>, T>(x => x.Items),
                Value = root,
                QueryMaps = new List<IMap>(),
            };

            mapRoot.QueryMaps.Add(mapRoot);

            return new FluentRoot<T> {MapO = mapRoot};
        }
    }
}
